﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Media;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace Spelprojekt
{
    class Player
    {
        public string PlayerPicture = "SpelareRight";
        public Vector2 PosXY = new Vector2(20, 300);
        protected int jumping = 0;
        protected int walking = 4;
        public Player() { }
        public void Move() 
        {
            KeyboardState KeyState = Keyboard.GetState();


#region Jump
            if (KeyState.IsKeyDown(Keys.W) && PosXY.Y >=300)
            {
                jumping = -25;
                using (var JumpsoundPlayer = new SoundPlayer(@"\\edunet\dfs\home09\ht12\johcah121\My Documents\Datavetenskap\Objektorienterad programmering\JohannesCarlsson\JohannesCarlsson\Spelprojekt\SpelprojektContent\Happyjump.wav"))
                {
                    JumpsoundPlayer.Play();
                }

            }
            if (PosXY.Y <= 300)
            {
                jumping +=2;
            }
            else if (!KeyState.IsKeyDown(Keys.W))
            {
                jumping = 0;
            }
            PosXY.Y += jumping;
#endregion Jump

#region Walk 

            if (KeyState.IsKeyDown(Keys.D))
            {
                PosXY.X += walking;
                //Banbytescroll framåt
                if(PosXY.X >= 800)
                {
                    PosXY.X = -55;
                }
            }

            if (KeyState.IsKeyDown(Keys.A))
            {
                PosXY.X -= walking;
                //Banbytescroll bakåt
                if (PosXY.X  <= 0)
                {
                    PosXY.X = 0;
                }
            }

#endregion Walk


        }


        
    }
}
